package com.gqb.reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;

public class reflectMethod {
	public static void main(String[] args) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		Method method=String.class.getMethod("charAt", int.class);
		System.out.println(method.invoke("abc", 2));
		Method[] methods=String.class.getDeclaredMethods();
		for (Method method2 : methods) {
			System.out.print(method2.getName());
			Type[] types=method2.getParameterTypes();
			System.out.print("(");
			for (Type type : types) {
				System.out.print(" "+type+" ");
			}
			System.out.print(")");
			System.out.println();
		}
		Method method3=reflectMethod.class.getMethod("print",int[].class);
		method3.invoke(null, new int[]{1,2,3});
	}
	public static void print(int[] objects){
		for (int i : objects) {
			System.out.println(i);
		}
	}
}
